package com.basic.modules.nykf.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.basic.common.utils.*;
import com.basic.modules.nykf.dao.JxSjDao;
import com.basic.modules.nykf.entity.JxSjEntity;
import com.basic.modules.nykf.service.JxSjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class JxSjServiceImpl extends ServiceImpl<JxSjDao, JxSjEntity> implements JxSjService {

    @Autowired
    JxSjDao jxSjDao;

    @Override
    public PageUtils getDlrZzhList(ParamsModel<JxSjEntity> params) {
        IPage<JxSjEntity> page = new Query<JxSjEntity>().getPage(BeanUtil.beanToMap(params.getPage()));
        IPage<JxSjEntity> dlrZzhList = baseMapper.getDlrZzhList(page, params.getCondition());
        return new PageUtils(dlrZzhList);
    }

    @Override
    public R postSjlr(JxSjEntity jxSjEntity) {
        Long userId = ShiroUtils.getUserId();
        jxSjEntity.setLrrUserId(userId);
        boolean save = this.save(jxSjEntity);
        if (save) {
            return R.ok();
        }
        return R.error();
    }
}